🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / common / src / commonMain / kotlin / org / meshtastic / core / common / util / UrlUtils.kt
Displaying Raw • Download
core/common/src/commonMain/kotlin/org/meshtastic/core/common/util/UrlUtils.kt 2d20cd8a4708e2ef66e98d5259f3a97ec93f240a (2d20cd8a) Text, 1.76 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.common.util
T8b949e/** Pure Kotlin URL encoding utility — no expect/actual needed. */
Tff7b72object T56d364UrlUtils Tb4b4b4{
T8b949e/**
* Percent-encodes a string for use in a URL query parameter (RFC 3986). Unreserved characters (A-Z, a-z, 0-9, `-`,
* `_`, `.`, `~`) are not encoded. Spaces are encoded as `%20` (not `+`).
*/
Tf0883e@SuppressTb4b4b4(Ta5d6ff"Ta5d6ffMagicNumberTa5d6ff"Tb4b4b4)
Tff7b72fun Td2a8ffencodeTb4b4b4(Te6edf3valueTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Tffa657String Tff7b72= Te6edf3buildString Tb4b4b4{
Tff7b72for Tb4b4b4(Te6edf3byte Tff7b72in Te6edf3valueTb4b4b4.Te6edf3encodeToByteArrayTb4b4b4(Tb4b4b4)Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3char Tff7b72= Te6edf3byteTb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3toCharTb4b4b4(Tb4b4b4)
Tff7b72if Tb4b4b4(Te6edf3charTb4b4b4.Te6edf3isUnreservedTb4b4b4(Tb4b4b4)Tb4b4b4) Tb4b4b4{
Te6edf3appendTb4b4b4(Te6edf3charTb4b4b4)
Tb4b4b4} Tff7b72else Tb4b4b4{
Te6edf3appendTb4b4b4(Ta5d6ff'%'Tb4b4b4)
Te6edf3appendTb4b4b4(Te6edf3HEX_DIGITSTff7b72[Tb4b4b4(Te6edf3byteTb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4) Te6edf3shr T79c0ff4Tb4b4b4) Te6edf3and T79c0ff0Te6edf3x0FTff7b72]Tb4b4b4)
Te6edf3appendTb4b4b4(Te6edf3HEX_DIGITSTff7b72[Te6edf3byteTb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4) Te6edf3and T79c0ff0Te6edf3x0FTff7b72]Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Tff7b72private Tff7b72fun Te6edf3CharTb4b4b4.Td2a8ffisUnreservedTb4b4b4(Tb4b4b4)Tb4b4b4: Tffa657Boolean Tff7b72= Tff7b72this Tff7b72in Ta5d6ff'A'Tb4b4b4.Tb4b4b4.Ta5d6ff'Z' Tff7b72|Tff7b72|
Tff7b72this Tff7b72in Ta5d6ff'a'Tb4b4b4.Tb4b4b4.Ta5d6ff'z' Tff7b72|Tff7b72|
Tff7b72this Tff7b72in Ta5d6ff'0'Tb4b4b4.Tb4b4b4.Ta5d6ff'9' Tff7b72|Tff7b72|
Tff7b72this Tff7b72=Tff7b72= Ta5d6ff'-' Tff7b72|Tff7b72|
Tff7b72this Tff7b72=Tff7b72= Ta5d6ff'_' Tff7b72|Tff7b72|
Tff7b72this Tff7b72=Tff7b72= Ta5d6ff'.' Tff7b72|Tff7b72|
Tff7b72this Tff7b72=Tff7b72= Ta5d6ff'~'
Tff7b72private Tff7b72val Te6edf3HEX_DIGITS Tff7b72= Ta5d6ff"Ta5d6ff0123456789ABCDEFTa5d6ff"Tb4b4b4.Te6edf3toCharArrayTb4b4b4(Tb4b4b4)
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.04s